package deamon;

/**
 * @program: javase
 * @description: 守护线程
 * @author: lld
 * @create: 2021-03-21 19:16
 **/
public class DeamonThread{
    public static void main(String[] args) {
        You you = new You();
        God god = new God();
        Thread thread = new Thread(god);
        thread.setDaemon(true);//设置为守护线程
        thread.start();
        new Thread(you).start();
    }
}
class You implements Runnable{

    @Override
    public void run() {
        for (int i=0;i<36500;i++){
            System.out.println("你活着");
        }
        System.out.println("离开世界");
    }
}
class God implements Runnable{

    @Override
    public void run() {
        while (true){
        System.out.println("守护你");
        }
    }
}
